package com.gao.one;

import com.gao.domain.Blog;
import com.gao.mapper.BlogMapper;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 这种方式自己手动获取sqlSession
 * 然后通过 mapper 接口调用。
 *
 * Service注入这个 Dao
 *
 * @author GaoXi
 * @date 2022/3/5 11:52
 */
@Component
public class OneDao extends SqlSessionDaoSupport implements BlogMapper {

    @Autowired
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public Blog selectBlog(Long id) {
        return getSqlSession().selectOne("com.gao.mapper.BlogMapper.selectBlog", id);
    }

    @Override
    public void insertBlog(Blog blog) {

    }



}
